<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=8">
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<meta content="B2B电商平台" name="description" />
		<meta content="B2B电商平台" name="keyword" />

		<title>B2B电商平台.运费模板</title>
		<link rel="icon" href="include/images/icss.ico" type="image/x-icon" />
		<link rel="shortcut icon" href="include/images/icss.ico" type="image/x-icon" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/global.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/style.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/pro.css" />
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/css/proManage.css" />
		<link rel="stylesheet" href="<%=path%>/include/JQuery ui/css/smoothness/jquery-ui-1.7.3.custom.css" type="text/css"></link>
		<link rel="stylesheet" type="text/css" href="<%=path%>/include/pagination/page.css" media="all">
			
		<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
		<script type="text/javascript" src="<%=path%>/include/js/jquery-1.8.0.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/cookies.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/icss.busin.js"></script>
		<script type="text/javascript" src="<%=path%>/include/JQuery ui/js/jquery-ui-1.7.3.custom.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/icss.common.js"></script>
		<script type="text/javascript" src="<%=path%>/include/pagination/jquery.pagination.js"></script>
		<script type="text/javascript" src="<%=path%>/include/pagination/init.js"></script>
		<script type="text/javascript" src="<%=path%>/include/js/doT.min.js"></script>
		<script type="text/javascript" src="<%=path%>/include/layer/layer.js"></script>
		<style type="text/css">
.table tr td {
	border-left: 1px solid #ddd;
	border-bottom: 1px solid #ddd;
	height: 33px;
}

.table tr th {
	border-left: 1px solid #ddd;
	font-weight: bold;
}
em.create {
    background-position: -50px -44px;
    line-height: 28px;
    display: inline-block;
    font-style: normal;
    background-repeat: no-repeat;
    text-indent: 15px;
    float: right;
    cursor: pointer;
}
#queryId button{
	background-image: url("<%=path%>/include/css/img/xs_bgx.png");
    background-color: transparent;
}
.cxx_btn{
	width: 44px;
    height: 24px;
    background-position: 0px -203px;
    line-height: 24px;
    margin: 0px 0px 0px 5px;
}

</style>
<script type="text/javascript">
	$(function(){
		_search();
	});

	var pagination;                         
	function _search() {
		var url = "<%=path%>/shippingTemplate/queryShippingTemplateList.do";
		var data = {
			tempName:$("#tempName").val(),
			priceType:$("#priceType").val(),
			isFree:$("#isFree").val(),
			status:$("#status").val()
		};
		pagination = _initPagination({'pageId':'pagination','cKey':'shippingTemplate', 'url': url, 'data': data, 'rows': 10, 'callback':_initDataList});
	}
	
	function _initDataList(data) {
 		var d = data.rows;
 		var total = data.total;
		var str = "";
		$("#tbody").empty();
		for(var i=0;i<d.length;i++){
			var shopId = d[i].SHOP_ID;
			str += "<tr>";
			str += "    <td>"+d[i].PID+"</td>";
			str += "    <td style='text-align:left;'>"+d[i].TEMP_NAME+"</td>";
			str += "    <td style='text-align:center;'>"+d[i].IS_FREE+"</td>";
			str += "    <td style='text-align:center;'>"+d[i].PRICE_TYPE+"</td>";
			str += "    <td style='text-align:left;'>"+d[i].DELIVERY_TIME+"</td>";
			str += "    <td style='text-align:center;'>"+d[i].CREATE_TIME+"</td>";
			if(d[i].STATUS=="1"){
				str += "    <td style='text-align:center;'>启用</td>";
				str += "    <td style='text-align:center;border-right: 1px solid #ddd;'><a href='javascript:void(0)' onclick='_changeStatus(\""+d[i].TEMPLATE_ID+"\",\"0\")'>禁用</a> | <a href='javascript:void(0)' onclick='_getInfo(\""+d[i].TEMPLATE_ID+"\",\"info\")'>详情</a></td>";
			}else{
				str += "    <td style='text-align:center;'>禁用</td>";
				str += "    <td style='text-align:center;border-right: 1px solid #ddd;' nowrap><a href='javascript:void(0)' onclick='_changeStatus(\""+d[i].TEMPLATE_ID+"\",\"1\")'>启用</a> | <a href='javascript:void(0)' onclick=\"_getInfo('"+d[i].TEMPLATE_ID+"','edit')\">编辑</a> | <a href='javascript:void(0)' onclick=\"_delInfo('"+d[i].TEMPLATE_ID+"')\">删除</a></td>";
			}
			str +=" </tr>";
		}
		$("#tbody").append(str);
		_reHeight("rightFrame","contentDiv");
		
	}	

	function _changeStatus(uuid,status){
		$.ajax({
			 type:"post",
			 url:"<%=path %>/shippingTemplate/updateStatus.do",
			 dataType:"text",
			 data:{uuid:uuid,status:status},
			 success:function(data){
				 var val = status == '1' ? '启用' : '禁用';
				 if("T"==data){
					 parent.layer.alert(val+"成功");
				 	_search();
				 }else{
					 parent.layer.alert(val+"失败");
				 }
			 }
		 });
	}

	function _delInfo(uuid){
		$.ajax({
			 type:"post",
			 url:"<%=path %>/shippingTemplate/delInfo.do",
			 dataType:"text",
			 data:{uuid:uuid},
			 success:function(data){
				 var val = "删除";
				 if("T"==data){
					parent.layer.alert(val+"成功");
				 	_search();
				 }else{
					 parent.layer.alert(val+"失败");
				 }
			 }
		 });
	}

	function _getInfo(uuid,flag){
		window.location.href = "<%=path %>/shippingTemplate/toAddOrUpdatePage.do?uuid="+uuid+"&pageFlag="+flag;
	}

</script>
	</head>
	<body style="font-family: '微软雅黑';">
		<div id="contentDiv" style="padding:4px; width:99%;">
			<div class="colnums-2-ab-b" style="overflow-x:auto;">
				<div class="toptil" >运费模板</div>
				<div id="queryId" style="border: 1px solid #e0e0e0;background: #f5f5f5;padding-left:10px;margin-bottom:10px;height: 40px;line-height: 40px;font-size:14px;">
					模板名称:&nbsp;<input id="tempName" name="tempName" style="height: 24px;width: 120px;padding-left: 3px"/>	
					计价方式:&nbsp;
					<select id="priceType" name="priceType" style="height: 24px;">
						<option value="">请选择</option>
						<option value="1">按件数</option>
						<option value="2">按金额</option>
					</select>				
					是否包邮:&nbsp;
					<select id="isFree" name="isFree" style="height: 24px;">
						<option value="">请选择</option>
						<option value="1">是</option>
						<option value="0">否</option>
					</select>				
					启用/禁用:&nbsp;
					<select id="status" name="status" style="height: 24px;">
						<option value="">请选择</option>
						<option value="1">启用</option>
						<option value="0">禁用</option>
					</select>				
					<button class="cxx_btn" type="button" onclick="_search()">查询</button>					
					<button class="cxx_btn" type="button" onclick="_getInfo('','')">新增</button>					
				</div>				
				<div class="row-fluid dataTables_wrapper" style="width:100%;">
					<table id="listTable" class="table table-hover table-nomargin table-bordered usertable dataTable"
						style="width: 100%; border-spacing: 0;text-align: center;line-height: 31px;">
						<thead>
							<tr class="trBgd"
								style="background-color: #eee;text-align: center; height: 31px; border: 1px solid #ddd; white-space: nowrap; background-position: 0 -123px; line-height: 30px; font-weight: bold;">
								<th style="width: 5%">
									序号
								</th>
								<th >
									模板名称
								</th>
								<th style="width: 10%">
									是否包邮
								</th>
								<th style="width: 10%">
									计价方式
								</th>
								<th style="width: 10%">
									发货时间
								</th>
								<th style="width: 20%">
									更新时间
								</th>
								<th style="width: 10%">
									状态
								</th>
								<th style="width: 10%">
									操作
								</th>
							</tr>
						</thead>
						<tbody id="tbody" style="font-size: 13px">
						</tbody>
					</table>
					<div class="dataTables_paginate paging_full_numbers">
						<span id="innerHtml"> </span>
					</div>
					<div id="pagination"></div>
					<div>
						<div style="height: 30px;"></div>
						<!-- 分类列表div结束 -->
						<div class="clear"></div>
					</div>
				</div>
				</div>
			</div>
	</body>
<script type="text/javascript">
	$(document).ready(function(){
			_reHeight("rightFrame","contentDiv");
	 });
</script>
	
</html>
